// 基于准备好的dom，初始化echarts实例
var myChart2 = echarts.init(document.getElementById('down2'),'macarons');

var seriesdata1 = [
    //[
    //
    //    60,80,45,65,55,65,92,52,74,82,65,83,72,90,55,75,54,57,98,58,89,58,92,82,67,100,70,92,72,83,68,55,64,60,83,64,99,77,82,80,75,93,85,62,76,56,96
    //
    //
    //
    //],
    //[
    //    58,92,82,67,100,75,93,85,70,92,72,83,68,55,64,60,83,64,99,77,60,80,45,65,55,65,92,52,74,82,65,83,72,90,82,80,55,75,54,57,98,58,89,62,76,56,96
    //
    //
    //]

    //[
    //   55,42,50,52,49,75,42,50,60,55,50
    //],
    //[
    //    40,62,42,40,45,62,35,40,50,90,40
    //]

    [
        30,
        40,
        30,
        28,
        35,
        45,
        20,
        30,
        40,
        60,
        30
    ],
    [
        40,
        30,
        40,
        45,
        32,
        35,
        40,
        40,
        30
    ]
];
InitChart(seriesdata1);
function InitChart(value){
    // 指定图表的配置项和数据
    var option = {
        tooltip : {
            trigger: 'axis',
            axisPointer: {
                type: 'cross',
                label: {
                    backgroundColor: '#6a7985'
                }
            }
        },
        color:['#ffff86','#79ffff'],
        legend:[

            {
                show:true,
                orient:'horizontal',
                x:'center',
                top:'3%',
                lineStyle:{

                },
                itemGap: 30,
                data:[
                    {
                        name:'XXXXX1'
                    },
                    {
                        name:'XXXXX2'
                    }
                ],
                textStyle:{
                    color:'#fff',
                    fontSize:40
                }
            }

        ],
        toolbox: {
            feature: {
                saveAsImage: {}
            }
        },
        grid: {
            left: '50',
            right: '80',
            bottom: '3%',
            containLabel: true
        },
        xAxis : [
            {
                type : 'category',
                boundaryGap : false,
                //data:val,
                data : ['2018/01','2018/02','2018/03','2018/04','2018/05','2018/06','2018/07'],
                axisLabel:{
                    show:true,
                    textStyle: {
                        color: '#fff',
                        fontSize:40
                    }

                },
                axisLine:{
                    lineStyle:{
                        color: '#56f0ed',
                        width:5
                    }
                }
            }
        ],
        yAxis :
        {
            name:'(%)',
            type : 'value',
            nameTextStyle:{
                color:"#fff",
                fontSize:40
            },
            min : 0,
            max:100,
            interval:10,
            //position: 'left',
            //nameLocation: 'middle',
            //nameGap: 35,
            axisLabel: {
                show: true,
                //interval: 'auto',
                //formatter: '{value}%',
                //position: 'left',
                //nameLocation: 'middle',
                //nameGap: 35,
                textStyle: {
                    color: '#fff',
                    fontSize:40
                }
            },
            show: true,
            splitLine:{
                show:false
            },
            axisLine:{
                lineStyle:{
                    color: '#56f0ed',
                    width: 5
                    //type: 'solid'
                }
            }
        },
        series : [
            {
                name:'XXXXX2',
                type:'line',
                symbol: 'circle',
                symbolSize:25, //拐点圆的大小
                smooth:true,
                //stack: '总量',
                areaStyle: {
                    color: new echarts.graphic.LinearGradient(
                        0, 0, 0, 1,
                        [
                            {offset: 0, color: 'rgb(255, 255, 71)'},
                            {offset: 0.5, color: 'rgb(255, 255, 71,0.8)'},
                            {offset: 1, color: 'rgb(255, 255, 71,0)'}
                        ]
                    )
                },
                //data:[38, 58, 40, 39, 40, 55, 30,35,50,80,40,70],
                markLine: {
                    symbol: ['none', 'none'],//去掉箭头

                    silent: true,
                    itemStyle: {
                        normal: { lineStyle: {width:1, type: 'solid', color:'#ccc' },label: { show: true, position:'left' } }
                    },
                    data:[
                        { name: '最小值',yAxis:0},
                        { name: '最大值',yAxis:90}
                    ]
                    //data:[{yAxis: 20},{yAxis: 40}]
                },
                data:value[1],
                lineStyle: {
                    normal: {
                        color: 'rgb(255,255,160)',
                        width: 10
                    }
                },
                itemStyle:{
                    normal:{


                    }
                },
                markArea:{
                }
            },
            {
                name:'XXXXX1',
                type:'line',
                symbol: 'circle',
                symbolSize:25, //拐点圆的大小
                //showSymbol: false,
                smooth:true,
                //stack: '总量',
                areaStyle: {
                    color: new echarts.graphic.LinearGradient(
                        0, 0, 0, 1,
                        [
                            {offset: 0, color: 'rgb(0, 242, 255)'},
                            {offset: 0.5, color: 'rgb(0, 242, 255,0.8)'},
                            {offset: 1, color: 'rgb(0, 242, 255,0)'}
                        ]
                    )
                },
                //data:[55, 40, 50, 52, 45, 75, 39,50,60,50,45,90],
                data:value[0],
                lineStyle: {
                    normal: {
                        color: 'rgb(0, 255, 255)',
                        width: 10
                    }
                },
                itemStyle:{
                    normal: {

                        barBorderRadius: 5
                    }
                }
            }

        ]
    };

    // 使用刚指定的配置项和数据显示图表。
    myChart2.setOption(option);
    window.onresize = function() {//监听div和屏幕的改变
        myChart2.resize();//resize属性指定一个元素是否是由用户调整大小的。
    }
}
    setInterval(function(){
        var op = myChart2.getOption();
        var opData0 = op.series[0].data;
        var opData1 = op.series[1].data;
        op.series[0].data.push(opData0.shift());
        op.series[1].data.push(opData1.shift());
        //opData0.shift();
        //opData1.shift();
        //op.xAxis[0].data.shift();
        myChart2.setOption(op);
    },5000);



